var e = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../@babel/runtime/regenerator")), t = require("../../../@babel/runtime/helpers/asyncToGenerator"), a = getApp();

Page({
    data: {
        page_id: "",
        shareInfo: {},
        codeShow: !1,
        acp: !1
    },
    onLoad: function(e) {
        if (e.scene) {
            var t = decodeURIComponent(e.scene);
            if (t) {
                var o = [];
                o = t.split(",");
                for (var i = 0; i < o.length; i++) {
                    var s;
                    s = o[i].split("="), console.log(s), "page_id" == s[0] && this.setData({
                        page_id: s[1]
                    }), "mid" == s[0] && a._setMid(s[1]), "acp" == s[0] && (this.setData({
                        acp: !0
                    }), this.getData());
                }
            }
        }
        e.mid && a._setMid(e.mid), e.page_id && (this.setData({
            page_id: e.page_id
        }), this.getData());
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.getData();
    },
    onReachBottom: function() {},
    onShareAppMessage: function() {
        var e = wx.getStorageSync("yz_uid"), t = "";
        return e && (t = e), {
            title: this.data.shareInfo.title,
            path: "/packageG/pages/diyCategory/diyCategory?page_id=" + this.data.page_id + "&mid=" + t,
            imageUrl: this.data.shareInfo.icon
        };
    },
    AddCart: function() {
        var e = this.selectComponent("#categoryCart");
        e && e.getCart();
    },
    cartShowClose: function(e) {
        if (e.detail) {
            console.log("购物车弹出close");
            var t = this.selectComponent("#categorySort");
            t && t.updateData();
        }
    },
    getData: function() {
        var e = this, t = a.getNetAddresss("home-page.index"), o = {
            page_id: this.data.page_id
        };
        a._getNetWork({
            url: t,
            data: o,
            success: function(t) {
                var a = t.data;
                if (1 == a.result) {
                    e.data.acp && e.address_codeMethod(a.data.basic_info);
                    var o = a.data.item;
                    e.setData({
                        components: o.datas
                    });
                    var i = a.data.item.page_info;
                    e.data.shareInfo = {
                        title: i.page_title,
                        icon: i.page_icon,
                        des: i.page_description
                    }, wx.setNavigationBarTitle({
                        title: a.data.item.page_name
                    });
                } else wx.showToast({
                    title: a.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    address_codeMethod: function() {
        var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : wx.getStorageSync("yz_basic_info"), t = e;
        t.plugin_setting.address_code && t.plugin_setting.address_code.enable && this.addressPopup();
    },
    closeChild: function() {
        this.setData({
            codeShow: !1
        });
    },
    onClickLeft: function() {
        this.setData({
            codeShow: !1
        });
    },
    addressPopup: function() {
        var a = this;
        this.setData({
            codeShow: !0
        }), setTimeout(t(e.default.mark(function t() {
            var o, i;
            return e.default.wrap(function(e) {
                for (;;) switch (e.prev = e.next) {
                  case 0:
                    return (o = a.selectComponent("#yz_showAddress")).setData({
                        addressCodeHospital: !1,
                        HospitalForm: {}
                    }), e.next = 4, o.getDefaultAddress();

                  case 4:
                    (i = e.sent) && (o.code_editAddress(i), o.getIsOpenAddress());

                  case 6:
                  case "end":
                    return e.stop();
                }
            }, t);
        })), 1e3);
    }
});